$(document).ready(function () {
    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return (r[2]); return null;
    }
    var one_id=GetQueryString("one_id");
    var two_id=GetQueryString("two_id");
    var Json={};
    Json["oneId"]=one_id;
    Json["twoId"]=two_id;

    //加载应用宝典三级九宫格
    $.post("../Index/checkThreeItem",Json, function (response) {
        var title=decodeURI(GetQueryString("title"));//decodeURI()将中文转换成字符串
        document.getElementById("titleName").innerHTML = title;
        var testJson = eval(response);
        $("#1-2-3").html("");
        if (testJson.length>1) {
            for (var i = 0; i < testJson.length; i++) {
                if ((i + 1) % 3 == 0) {
                    $("#1-2-3").append(
                        '<li>' +
                        '<button type="button" one_id="' + testJson[i]["ONE_ID"] + '" two_id="' + testJson[i]["TWO_ID"] + '" three_id="' + testJson[i]["THREE_ID"] + '"  title="' + testJson[i]["THREE_NAME"] + '">' +
                        '<img alt="" src="../Content/Images/logo/' + testJson[i]["THREE_IMG"] + '" /></button>' +
                        '<span>' + testJson[i]["THREE_NAME"] + '</span>' +
                        '</li>' +
                        '<div class="clearfix"></div>'
                    );
                } else {
                    $("#1-2-3").append(
                        '<li>' +
                        '<button type="button" one_id="' + testJson[i]["ONE_ID"] + '" two_id="' + testJson[i]["TWO_ID"] + '" three_id="' + testJson[i]["THREE_ID"] + '"  title="' + testJson[i]["THREE_NAME"] + '">' +
                        '<img alt="" src="../Content/Images/logo/' + testJson[i]["THREE_IMG"] + '" /></button>' +
                        '<span>' + testJson[i]["THREE_NAME"] + '</span>' +
                        '</li>'
                    );
                }
            }
        }else {
            alert(testJson[0]["failInfo"]);
        }
        $("button[one_id]").click(function () {
            location.href = "../page/fourindex?one_id=" + $(this).attr("one_id")+"&two_id="+$(this).attr("two_id")+"&three_id="+$(this).attr("three_id")+"&title="+$(this).attr("title");
        });
    });


});